package com.just.springbootactuator;

import org.springframework.boot.actuate.endpoint.AbstractEndpoint;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

@ConfigurationProperties(prefix = "endpoint.status",ignoreUnknownFields = false)
public class StatusEndPoint extends AbstractEndpoint<String> implements ApplicationContextAware {
    ApplicationContext applicationContext;
    public StatusEndPoint(){
        super("status");
    }
    @Override
    public String invoke() {
        StatusService statusService=applicationContext.getBean(StatusService.class);
        return "The currentStatus is:"+statusService.getStatus();
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }
}
